- ex daemons are known as service units. *.service
# Available units
systemctl -t help # --type help
Used to group other units together and to bring the system to certain states. (Runlevel)
Default target:
systemctl get-default
set-default graphical.target
Default target paths:
ll /etc/systemd/system/default.target
ll /lib/systemd/system/default.target
Going into a target:
# AllowIsolate=yes (isolation must be yes)
systemctl isolate graphical.target # same as: telinit runlevel
rescue = 1 user
"rescue" is equivalent to the old runlevel 1 everything is mounted, but no normal services are started
emergency = nothing but systemd
No services are started, no mount points mounted no sockets established, good for debugging step by step
systemctl rescue # like isolate rescue but sends a wall message
systemctl --no-wall rescue
systemd.unit=rescue.target # same as old school: 1 at the end of kernel line
systemctl start name.service
systemctl stop name.service
# Stop, then start again.
systemctl restart name.service
# Restarts a service only if it is running.
systemctl try-restart name.service
If the application in question is able to reload its configuration files (without restarting), you can issue the reload command to initiate that process.
# Reloads configuration.
systemctl reload name.service
# try to reload if can't restarts
systemctl reload-or-restart name.service
systemctl try-reload-or-restart name.service
systemctl status name.service
systemctl is-active name.service # running
systemctl is-enabled name.service # will be activated when booting
systemctl is-failed name.service # tried to active but failed
systemctl enable name.service
systemctl disable name.service
# combination of disable and enable and is useful to reset the symlinks
systemctl reenable name.service
you can mask any service unit to prevent it from being started manually or by another service:
# links /etc/systemd/system/name.service -> /dev/null
systemctl mask name.service
systemctl unmask name.service
# list (all kind of units) [loaded and active]
systemctl list-units
# --all = active or not (inactive, dead, not-found, etc)
# list (all kind of units) [loaded] active or not
systemctl list-units --all
# list (service units) [loaded and currently active]
systemctl list-units --type=service
# list (target units) [loaded] active or not
systemctl list-units --type=target --all
# list (service units) [loaded but currently inactive]
# if we don't use --all it's only shows active ones
systemctl list-units --all --type=service --state=inactive
# list (target units) [ltried to load but not found]
systemctl list-units --all --type=target --state=not-found
list-units only displays units that systemd has attempted to load (wanted by).
To see every available unit file including those that systemd has not attempted to load:
# list all [available] service units to see if they are enabled or not
systemctl list-unit-files --type service # can be used for other units like: targets etc.
systemd-networkd-resolvconf-update.path static
accounts-daemon.service enabled
alsa-utils.service masked # /dev/null
console-getty.service disabled
systemctl list-unit-files --state masked | head -3
static: unit file does not contain an "install" section. these units cannot be enabled and these are used only as a dependency of another units.
vimcat /lib/systemd/system/systemd-networkd-resolvconf-update.path
# vimcat /lib/systemd/system/colord.service
vimcat /lib/systemd/system/accounts-daemon.service # systemctl cat accounts-daemon.service
systemctl list-dependencies multiuser.target
systemctl list-dependencies --after *.service/target
systemctl list-dependencies --before *.service/target
# Alias
systemctl show multi-user.target -p Names
# Controlling systemd on a Remote Machine
systemctl --host user_name@host_name command
ipynb
format: https://github.com/ravexina/linux-notes. html
exports of project available at: https://ravexina.github.io/linux-notes.Linux Notes by Milad As (Ravexina) is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.